<template>
    <section class="home-container" id="home">
        <div class="content-wrap" :style="{ 'padding-top': isShowNotice ? '50px' : 0 }">

            <div class="content content1">
                <a-carousel autoplay>
                    <div>
                        <div style="position: relative;">
                            <img style="height:6.65rem;width:100%;" :src="handleImg('index/banner1.png')" alt="">
                            <div class="authentication" @click="goAuth('roleAuth')"></div>
                            <div class="member" @click="goDocs('/docs/help_document/coupon/member')"></div>
                        </div>
                    </div>
                    <div>
                        <img style="height:6.65rem;width:100%;" :src="handleImg('index/banner2.png')" alt="">
                    </div>
                </a-carousel>
                <div class="home-tabs">
                    <img @click="goDocs('/docs/help_document/quick_start/GPUpick')" :src="handleImg('index/home-tab1.png')"
                        alt="">
                    <img @click="goDocs('/docs/help_document/faq/price#如何索要发票')" :src="handleImg('index/home-tab2.png')"
                        alt="">
                    <img @click="goDocs('/docs/category/%E5%BF%AB%E9%80%9F%E5%BC%80%E5%A7%8B')"
                        :src="handleImg('index/home-tab3.png')" alt="">
                    <img @click="goDocs('/docs/category/%E8%96%85%E7%BE%8A%E6%AF%9B%E6%94%BB%E7%95%A5')"
                        :src="handleImg('index/home-tab4.png')" alt="">
                </div>
            </div>
            <div class="content content2" :style="{ backgroundImage: `url(${handleImg('index/content2-bg.png')})` }">
                <div class="content2-top">
                    <div class="content2-title">
                        <img :src="handleImg('index/content2-title.png')" alt="">
                        <div class="txt">现在即可注册并立即体验GpuMall,您也可以联系我们了解如何为您的企业提供定制化方案</div>
                        <div class="flex">
                            <div class="register" @click="router.push('/login')">立即注册</div>
                            <div class="contact-us" @click="modalVisible = true">联系在线客服</div>
                        </div>
                    </div>

                    <div class="content2-use1">
                        <img :src="handleImg('index/content2-use1-img.png')" alt="" @click="goDocsCard">
                        <div class="txt">了解我们的选型方案如何满足企业客户的定制化需求</div>
                    </div>
                    <div class="content2-use2">
                        <img :src="handleImg('index/content2-use2-img.png')" alt="" @click="goDocs('/docs')">
                        <div class="txt">查看我们的在线使用文档了解如何让使用</div>
                    </div>
                </div>

                <div class="content2-img">
                    <img :src="handleImg('index/content2-img.png')" alt="">
                </div>
            </div>
            <div class="content content3" :style="{ backgroundImage: `url(${handleImg('index/content3-bg.png')})` }">
                <div class="content3-title">
                    <img :src="handleImg('index/content3-title.png')" alt="">
                </div>
                <div class="content3-left scroll-item animate__fadeInLeft">
                    <img :src="handleImg('index/content3-left.png')" alt="">
                </div>
                <div class="content3-right scroll-item animate__fadeInRight">
                    <img :src="handleImg('index/content3-right.png')" alt="">
                </div>
            </div>
            <div class="content content4" :style="{ backgroundImage: `url(${handleImg('index/content4-bg.png')})` }">
                <div class="content4-left-bg">
                    <img :src="handleImg('index/content4-left-bg.png')" alt="">
                </div>
                <div class="content4-left scroll-item animate__bounceIn">
                    <img :src="handleImg('index/content4-left.png')" alt="">
                </div>
                <div class="content4-title-img">
                    <img :src="handleImg('index/content4-title-img.png')" alt="">
                    <div>主流公有云厂商数据一键同步</div>
                </div>
            </div>

            <footer class="content-bottom" :style="{ backgroundImage: `url(${handleImg('index/content-bottom-bg.png')})` }"
                v-if="!isMobile">
                <div class="logo">
                    <img :src="handleImg('index/logo.png')" alt="">
                </div>

                <div class="product">
                    <div class="title">产品</div>
                    <div class="txt">高可用云</div>
                    <div class="txt">社区云</div>
                </div>

                <div class="help">
                    <div class="title">帮助和支持</div>
                    <div class="txt" style="cursor: pointer;" @click="goDocs('/docs/help_document/quick_start/GPUpick')">如何选卡?</div>
                    <div class="txt" style="cursor: pointer;" @click="goDocs('/docs/help_document/faq/price#如何索要发票')">如何开票?</div>
                </div>


                <div class="contact-us">
                    <div class="title">联系我们</div>
                    <div>
                        <div class="contact-us-list">
                            <img :src="handleImg('index/phone.png')" alt="">
                            <span>咨询电话：18516569845</span>
                        </div>
                        <div class="contact-us-list">
                            <img :src="handleImg('index/email.png')" alt="">
                            <span>商务邮箱：business@gpumall.com</span>
                        </div>
                    </div>

                </div>

                <div class="qrcode">
                    <div class="qrcode-list">
                        <div class="title">客服咨询</div>
                        <div class="qrcode-wrap">
                            <img :src="handleImg('index/customer-service.png')" alt="">
                        </div>

                    </div>
                    <div class="qrcode-list">
                        <div class="title">关注领福利</div>
                        <div class="qrcode-wrap">
                            <img :src="handleImg('index/wechat.png')" alt="">
                        </div>
                    </div>
                </div>

                <div class="filings">
                    <a href="https://beian.miit.gov.cn" target="_blank">© Rights Reserved 2023
                        沪ICP备2021033122号-21</a>
                </div>
            </footer>


            <footer class="content-bottom"
                :style="{ backgroundImage: `url(${handleImg('index/content-bottom-mobile-bg.png')})` }" v-if="isMobile">
            </footer>

        </div>

        <!-- 联系客服 -->
        <a-modal v-model:visible="modalVisible" title="联系我们" @ok="handleOk">
            <div style="text-align: center;">
                <img style="width: 300px;height: 400px;" :src="handleImg('console/contact-us.png')" alt="">
            </div>
        </a-modal>


        <!-- 悬浮按钮 -->
        <div class="float-btn" v-if="!isMobile">
            <div class="title">
                <div>客服</div>
            </div>
            <div class="wechat">
                <img src="@/assets/img/console/wechat-contract.png" alt="">
                <div class="qr-code">
                    <img src="@/assets/img/console/customer-service.png" alt="">
                </div>
            </div>
        </div>

        <!-- 移动端悬浮 -->
        <div class="mb-float-btn" v-if="isMobile">
            <div class="title">
                <div>客服</div>
            </div>
            <div class="wechat">
                <img src="@/assets/img/console/wechat-contract.png" alt="">
                <div class="qr-code">
                    <img src="@/assets/img/console/customer-service.png" alt="">
                </div>
            </div>
        </div>

    </section>
</template>

<script setup>
import { onMounted, nextTick, watch, reactive, ref, defineProps } from 'vue'
import lazyLoadImages from '../../libs/util.lazyLoad'
import { useRouter } from 'vue-router'
import dayjs from 'dayjs';

const props = defineProps({
    isShowNotice: {
        type: Boolean,
        default: true
    }
})

const router = useRouter()

const modalVisible = ref(false)
const handleOk = () => {
    modalVisible.value = false
}

// 登录页面判断一下是否是移动端
const isMobile = ref(false)
function _isMobile() {
    let flag = navigator.userAgent.match(
        /(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i
    );
    // return flag;
    isMobile.value = flag
}

onMounted(() => {
    _isMobile()
    let html = document.documentElement;
    html.style.fontSize = 100 * (html.clientWidth / 1920) + "px";

    // 监听 window 的 resize 事件．在浏览器窗口变化时再设置下区域高度．
    window.onresize = () => {
        let html = document.documentElement;
        html.style.fontSize = 100 * (html.clientWidth / 1920) + "px";
    };

    lazyLoadImages()

    const wow = new WOW({
        // 对所有拥有该class的元素挂载动画
        boxClass: "scroll-item",
        // 需要挂载的动画元素
        animateClass: "animate__animated",
        // 偏移值（即偏移一定距离后再执行动画，推荐设置！）
        offset: 200,
        // 移动设备是否生效
        mobile: true,
        // 是否支持异步
        live: true,
    });

    wow.init();

})

function goDocs(key) {
    window.open(window.location.origin + key, '_blank')
}

function goDocsCard() {
    window.open(window.location.origin + '/docs/help_document/quick_start/GPUpick', '_blank')
}

const goAuth = (key) => {
    router.push({ path: '/account', query: { key } })
}

</script>

<style lang="scss" scoped>
.home-container {
    font-family: -apple-system, BlinkMacSystemFont, "opensans", "Optima", "Microsoft Yahei", sans-serif;
    height: 100%;
    position: relative;
    transition: all .4s linear;

    .main-warp {
        background-color: #FFF;
        box-sizing: border-box;
        width: 100%;

        ul {
            list-style-type: none;
        }
    }
}

.content-wrap {
    height: 100%;

    .content {
        position: relative;
        box-sizing: border-box;
        height: 10.8rem;
        background-size: 100% 100%;
    }

    .content1 {
        // height: 100vh;
        height: 6.65rem;

        :deep(.slick-dots-bottom) {
            bottom: 0.9rem;
        }

        .home-tabs {
            width: 100%;
            height: 1.46rem;
            position: absolute;
            top: 5.9rem;
            left: 0;
            padding: 0 1rem;
            display: flex;
            justify-content: space-between;
            z-index: 8;

            img {
                display: inline-block;
                width: 4rem;
                height: 1.46rem;
                cursor: pointer;
            }
        }

        .authentication {
            position: absolute;
            left: 7.06rem;
            top: 4.5rem;
            width: 1.68rem;
            height: 0.5rem;
            cursor: pointer;
        }

        .member {
            position: absolute;
            left: 9.61rem;
            top: 4.5rem;
            width: 1.68rem;
            height: 0.5rem;
            cursor: pointer;
        }
    }

    .content2 {
        padding-top: 1.75rem;

        .content2-top {
            display: flex;
            padding-left: 3.5rem;
            margin-bottom: 1rem;

            .txt {
                font-size: 0.16rem;
                color: #ffffff;
            }

            .content2-title {
                width: 4.8rem;
                margin-right: 1.9rem;

                img {
                    width: 4.8rem;
                    height: 0.72rem;
                    margin-bottom: 0.32rem;
                }

                .txt {
                    margin-bottom: 0.24rem;
                }

                .register {
                    width: 1.45rem;
                    height: 0.4rem;
                    background: #0077FF;
                    color: #ffffff;
                    font-size: 0.18rem;
                    margin-right: 0.24rem;
                    text-align: center;
                    line-height: 0.4rem;
                    border-radius: 4px;
                    cursor: pointer;
                }

                .contact-us {
                    height: 0.4rem;
                    line-height: 0.4rem;
                    font-size: 0.16rem;
                    color: #0077FF;
                    cursor: pointer;
                }
            }

            .content2-use1 {
                width: 2.6rem;
                margin-right: 1.2rem;

                img {
                    width: 1rem;
                    height: 0.7rem;
                    cursor: pointer;
                }

                .txt {
                    margin-top: 0.4rem;
                }
            }

            .content2-use2 {
                img {
                    width: 1rem;
                    height: 0.7rem;
                    cursor: pointer;
                }

                .txt {
                    margin-top: 0.4rem;
                }
            }
        }

        .content2-img {
            text-align: center;

            img {
                width: 7.06rem;
                height: 3.97rem;
            }
        }
    }

    .content3 {
        padding-top: 0.89rem;
        text-align: center;
        position: relative;

        .content3-title {
            img {
                width: 5rem;
                height: 0.72rem;
            }
        }

        .content3-left {
            position: absolute;
            left: 2.27rem;
            top: 2.21rem;

            img {
                width: 10.34rem;
                height: 4.38rem;
            }
        }

        .content3-right {
            position: absolute;
            right: 2.22rem;
            top: 6.5rem;

            img {
                width: 10.34rem;
                height: 4.38rem;
            }
        }
    }

    .content4 {
        position: relative;

        .content4-left-bg {
            position: absolute;
            left: 1.3rem;
            top: 0.6rem;

            img {
                width: 9.6rem;
                height: 9.6rem;
            }

        }

        .content4-left {
            position: absolute;
            left: 4.17rem;
            top: 2.6rem;

            img {
                width: 4.05rem;
                height: 4.88rem;
            }
        }

        .content4-title-img {
            position: absolute;
            left: 11.9rem;
            top: 5.34rem;

            img {
                width: 5rem;
                height: 0.72rem;
            }

            div {
                color: #FFF;
                font-size: 0.24rem;
                font-style: normal;
                font-weight: 600;
                line-height: normal;
                margin-top: 0.24rem;
                margin-left: 0.7rem;
            }
        }
    }

    .content-bottom {
        position: relative;
        height: 2.8rem;
        box-sizing: border-box;
        background-size: 100% 100%;
        padding-top: 0.5rem;
        display: flex;
        padding-right: 1.3rem;

        .filings {
            position: absolute;
            bottom: 0.3rem;
            left: 8rem;

            a {
                color: #FFF;
                font-size: 0.14rem;
                font-style: normal;
                font-weight: 400;
            }
        }

        .title {
            color: #FFF;
            font-size: 0.2rem;
            font-style: normal;
            font-weight: 600;
            line-height: normal;
        }

        .logo {
            margin-right: 1.2rem;
            display: flex;
            align-items: center;
            padding-left: 0.32rem;

            img {
                width: 1.5rem;
                height: 0.4rem;
            }
        }

        .contact-us,
        .help,
        .product {
            .title {
                margin-bottom: 0.6rem;
            }

            .txt {
                color: #FFF;
                font-size: 0.16rem;
                font-style: normal;
                font-weight: 600;
                line-height: normal;
                margin-bottom: 0.16rem;
            }
        }

        .product {
            margin-right: 1.08rem;
        }

        .help {
            margin-right: 2.56rem;
        }

        .contact-us {

            .contact-us-list {
                display: flex;
                align-items: center;
                margin-bottom: 0.16rem;

                img {
                    margin-right: 0.16rem;
                    width: 0.24rem;
                    height: 0.24rem;
                }

                span {
                    color: #FFF;
                    font-size: 0.16rem;
                    font-style: normal;
                    font-weight: 400;
                    line-height: normal;
                }
            }
        }

        .about {
            margin-right: 5.8rem;

            .doc {
                color: #FFF;
                font-size: 0.16rem;
                font-style: normal;
                font-weight: 600;
                line-height: normal;
                margin-top: 0.16rem;
                cursor: pointer;
            }
        }

        .qrcode {
            margin-left: auto;
            display: flex;


            .qrcode-list {
                margin-right: 0.16rem;

                .title {
                    margin-bottom: 0.35rem;
                }

                img {
                    width: 1.27rem;
                    height: 1.27rem;
                }
            }
        }
    }

    .lefteaseinAnimate {
        animation: lefteaseinAnimate 1s ease 1;
        /*调用已定义好的动画lefteaseinAnimate，全程运行时间1S，进入的速度曲线为ease，只播放一次*/
        -webkit-animation: lefteaseinAnimate 1s ease 1;
        -ms-animation: lefteaseinAnimate 1s ease 1;
        -o-animation: lefteaseinAnimate 1s ease 1;
        -moz-animation: lefteaseinAnimate 1s ease 1;

        /*规定动画的最后状态为结束状态*/
        animation-fill-mode: forwards;
        -webkit-animation-fill-mode: forwards;
        -o-animation-fill-mode: forwards;
        -ms-animation-fill-mode: forwards;
        -moz-animation-fill-mode: forwards;
    }

    .content-left {
        .ours-product {
            margin-top: 1.69rem;
            height: 0.62rem;
            font-size: 0.44rem;
            font-weight: 500;
            color: rgba(51, 51, 51, 0.08);
            line-height: 0.62rem;
            position: relative;

            .title {
                position: absolute;
                left: 0;
                top: 0;
                height: 0.4rem;
                font-size: 0.28rem;
                font-weight: 500;
                color: #333333;
                line-height: 0.4rem;
            }
        }

        .line {
            width: 0.31rem;
            height: 5px;
            background: #0064E7;
            border-radius: 3px;
            margin-top: 1.4rem;
        }

        .product-info {
            width: 5.06rem;
            margin-top: 0.40rem;

            div {
                text-align: left;
                height: 0.3rem;
                font-weight: 500;
                color: #333333;
                font-size: 0.22rem;
                line-height: 0.30rem;
            }
        }

        .about-us {
            width: 1.4rem;
            text-align: center;
            height: 0.52rem;
            border-radius: 35px;
            border: 2px solid #0064E7;
            line-height: 0.52rem;
            font-size: 0.2rem;
            font-weight: 500;
            color: #0064E7;
            margin-top: 0.48rem;

        }
    }

    .righteaseinAnimate {
        animation: righteaseinAnimate 1s ease 1;
        /*调用已定义好的动画righteaseinAnimate，全程运行时间1S，进入的速度曲线为ease，只播放一次*/
        -webkit-animation: righteaseinAnimate 1s ease 1;
        -moz-animation: righteaseinAnimate 1s ease 1;
        -ms-animation: righteaseinAnimate 1s ease 1;
        -o-animation: righteaseinAnimate 1s ease 1;

        /*规定动画的最后状态为结束状态*/
        animation-fill-mode: forwards;
        -webkit-animation-fill-mode: forwards;
        -o-animation-fill-mode: forwards;
        -ms-animation-fill-mode: forwards;
        -moz-animation-fill-mode: forwards;
    }

    .content-right {
        margin-top: 2.25rem;

        .content2-img {
            display: inline-block;
            width: 9.08rem;
            height: 5.88rem;
        }

        .content-right-list-wrap {
            display: flex;
            padding-top: 0.72rem;
        }

        .content-right-list {
            width: 2.67rem;
            height: 3.93rem;
            background: #FFFFFF;
            box-shadow: 0px 2px 0.13rem 0px rgba(0, 0, 0, 0.1);
            border-radius: 0.2rem;
            text-align: center;
            margin-right: 0.7rem;

            .con-list-top {
                height: 2.9rem;
                overflow: hidden;
                position: relative;
            }

            .con-list-box:hover .con-list-top1 {
                animation: fade-out 0.5s ease-in-out 0s 1;
                animation-fill-mode: forwards;

            }

            .con-list-box:hover .con-list-top2 {
                animation: fade-in 0.5s ease-in-out 0.5s 1;
                animation-fill-mode: forwards;

            }

            .con-list-top1 {
                padding: 0.63rem 0 0.53rem 0;
                opacity: 1;

                img {
                    display: block;
                    margin: 0 auto;
                    ;
                }

                .content3-img1 {
                    width: 0.81rem;
                    height: 0.78rem;
                }

                .content3-img2 {
                    width: 0.88rem;
                    height: 0.79rem;
                }

                .content3-img3 {
                    width: 0.94rem;
                    height: 0.79rem;
                }

                .title1 {
                    height: 0.33rem;
                    font-size: 0.24rem;
                    font-weight: 500;
                    color: #333333;
                    line-height: 0.33rem;
                    margin-top: 0.35rem;
                }

                .title2 {
                    margin-top: 0.05rem;
                    height: 0.22rem;
                    font-size: 0.16rem;
                    font-weight: 500;
                    color: #666666;
                    line-height: 0.22rem;
                }
            }

            .con-list-top2 {
                position: absolute;
                left: 0;
                top: 0;
                padding-top: 0.34rem;
                opacity: 0;
                width: 100%;

                img {
                    display: block;
                    margin: 0 auto;
                    ;
                }

                .content3-img1 {
                    width: 0.45rem;
                    height: 0.43rem;
                }

                .content3-img2 {
                    width: 0.47rem;
                    height: 0.43rem;
                }

                .content3-img3 {
                    width: 0.55rem;
                    height: 0.45rem;
                }

                .title1 {
                    height: 0.33rem;
                    font-size: 0.24rem;
                    font-weight: 500;
                    color: #333333;
                    line-height: 0.33rem;
                    margin-top: 0.26rem;
                }

                .title2 {
                    margin-top: 0.05rem;
                    height: 0.22rem;
                    font-size: 0.16rem;
                    font-weight: 500;
                    color: #666666;
                    line-height: 0.22rem;
                }

                .txt {
                    margin-top: 0.2rem;
                    font-size: 0.14rem;
                    font-weight: 400;

                    div {
                        color: #999999;
                        line-height: 0.2rem;
                    }
                }
            }

            .con-list-bottom {
                padding: 0.18rem 0 0.25rem;
                background: linear-gradient(270deg, #4293FD 0%, #0064E7 100%);
                border-radius: 0 0 0.2rem 0.2rem;

                .count {
                    height: 0.33rem;
                    font-size: 0.24rem;
                    font-weight: 500;
                    color: #FFFFFF;
                    line-height: 0.33rem;
                }

                .info {
                    margin-top: 5px;
                    height: 0.22rem;
                    font-size: 0.16rem;
                    font-weight: 500;
                    color: rgba(255, 255, 255, 0.7);
                    line-height: 0.22rem;
                }
            }
        }
    }
}


.float-btn {
    position: fixed;
    right: 0.28rem;
    top: 4.66rem;
    height: 1.2rem;
    background: #ffffff;
    border-radius: 0.5rem;
    padding: 0.24rem 0 0.18rem 0;
    z-index: 99;

    .title {
        padding: 0 0.2rem;
        color: #223354;
        font-size: 0.14rem;
        font-style: normal;
        font-weight: 400;

        div {
            border-bottom: 1px solid #D7D9DD;
            padding-bottom: 0.08rem;
        }
    }

    .wechat {
        width: 0.42rem;
        height: 0.42rem;
        border-radius: 50%;
        border: 1px solid #D7D9DD;
        display: flex;
        align-items: center;
        justify-content: center;
        margin: 0.08rem auto 0;
        cursor: pointer;
        position: relative;

        img {
            width: 0.26rem;
            height: 0.23rem;
        }
    }

    .qr-code {
        display: block;
        position: absolute;
        left: -0.3rem;
        top: -0.3rem;
        transform: scale(0);
        opacity: 0;
        transition: all .5s ease;

        img {
            width: 1.48rem;
            height: 1.48rem;
        }
    }

    .wechat:hover {
        .qr-code {
            left: -1.7rem;
            transform: scale(1);
            opacity: 1;
        }
    }
}


.mb-float-btn {
    position: fixed;
    right: 14px;
    top: 233px;
    height: 75px;
    background: #ffffff;
    border-radius: 25px;
    padding: 12px 0 9px 0;
    z-index: 99;

    .title {
        padding: 0 10px;
        color: #223354;
        font-size: 10px;
        font-style: normal;
        font-weight: 400;

        div {
            border-bottom: 1px solid #D7D9DD;
            padding-bottom: 8px;
        }
    }

    .wechat {
        width: 21px;
        height: 21px;
        border-radius: 50%;
        border: 1px solid #D7D9DD;
        display: flex;
        align-items: center;
        justify-content: center;
        margin: 8px auto 0;
        cursor: pointer;
        position: relative;

        img {
            width: 13px;
            height: 12px;
        }
    }

    .qr-code {
        display: block;
        position: absolute;
        left: -15px;
        top: -15px;
        transform: scale(0);
        opacity: 0;
        transition: all .5s ease;

        img {
            width: 54px;
            height: 54px;
        }
    }

    .wechat:hover {
        .qr-code {
            left: -60px;
            transform: scale(1);
            opacity: 1;
        }
    }
}
</style>
